/*
* =====================================================================================
*
* Filename: main.cpp
*
* Description:
*
* Version: 1.0
* Created: 22/06/2009 21:16:05
* Revision: none
* Compiler: gcc
*
* Author: John Ryland (jryland), jryland@xiaofrog.com
* Company: InvertedLogic
*
* =====================================================================================
*/
#include <stdio.h>
#include "DebugMemory.h"
void function(int size);
void function2(int size);
class Blah {
public:
Blah(int x) { a = x; b = x; c = x; d = x; e = x; }
Blah() { a = 1; b = 2; c = 3; d = 4; e = 5; }
~Blah() { }
void dump() { printf("%i %i %i %i %i\n", a, b, c, d, e); }
private:
int a, b, c, d, e;
};
int main(int argc, char *argv[])
{
Blah *a = new Blah();
Blah *b = new Blah;
Blah *c = new Blah(2);
Blah *d = new Blah[3];
a->dump();
b->dump();
c->dump();
d[0].dump();
d[1].dump();
d[2].dump();
function(10);
function(20);
function(30);
function2(10);
function2(20);
function2(30);
void *p1 = malloc(128);
void *p2 = calloc(2, 128);
void *p3 = realloc(p2, 257);
delete a;
delete b;
free(c);
delete[] d;
//free(p1);
free(p3);
DebugMemory::showMemoryLeaks();
DebugMemory::showMemoryAllocations();
return 0;
}